package o;

import android.app.Activity;
import android.content.Context;
import android.os.AsyncTask;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import com.huawei.appgallery.downloadengine.api.SessionDownloadTask;
import com.huawei.appgallery.foundation.application.pkgmanage.model.update.ApkUpgradeInfo;
import com.huawei.appmarket.service.store.awk.bean.SubstanceDeeplinkCardBean;
import java.lang.ref.WeakReference;
import java.util.LinkedHashMap;
import o.ewm.n;

public class dwz implements o.dws.d {
    private String ˊ;
    private SubstanceDeeplinkCardBean ˋ;
    private String ˎ;
    private Context ˏ;

    static class d extends AsyncTask<Void, Void, ApkUpgradeInfo> {
        private WeakReference<Context> ˊ;
        private String ˋ;
        private String ˏ;

        protected /* synthetic */ Object doInBackground(Object[] objArr) {
            return ˊ((Void[]) objArr);
        }

        protected /* synthetic */ void onPostExecute(Object obj) {
            ˏ((ApkUpgradeInfo) obj);
        }

        d(Context context, String str, String str2) {
            this.ˏ = str;
            this.ˊ = new WeakReference(context);
            this.ˋ = str2;
        }

        protected ApkUpgradeInfo ˊ(Void... voidArr) {
            Logger.ˎ("SubstanceDeeplinkEventListener", "CheckThirdAppUpdateTask doInBackground");
            ApkUpgradeInfo ॱ = dug.ॱ(this.ˏ);
            if (ॱ != null) {
                return ॱ;
            }
            if (this.ˊ != null && this.ˊ.get() != null) {
                return dss.ॱ().ˎ((Context) this.ˊ.get(), this.ˏ, 0, 1);
            }
            Logger.ˋ("SubstanceDeeplinkEventListener", "context == null");
            return null;
        }

        protected void ˏ(ApkUpgradeInfo apkUpgradeInfo) {
            if (this.ˊ == null) {
                Logger.ˋ("SubstanceDeeplinkEventListener", "contextWeakReference  == null");
                return;
            }
            Context context = (Context) this.ˊ.get();
            if (context == null) {
                Logger.ˋ("SubstanceDeeplinkEventListener", "context == null");
                return;
            }
            CharSequence string;
            if (apkUpgradeInfo != null) {
                string = context.getString(n.ᐨॱ, new Object[]{this.ˋ});
            } else {
                string = context.getString(n.ᐧॱ, new Object[]{this.ˋ});
            }
            evk.ॱ(string);
        }
    }

    public void ˏ(@NonNull Context context, @NonNull SubstanceDeeplinkCardBean substanceDeeplinkCardBean, String str, String str2) {
        this.ˏ = context;
        this.ˋ = substanceDeeplinkCardBean;
        this.ˎ = str;
        this.ˊ = str2;
        if (!erz.ˏ(context, str)) {
            ॱ(context, substanceDeeplinkCardBean);
        } else if (dwv.ˊ(substanceDeeplinkCardBean.ᶥ())) {
            ˎ(context, substanceDeeplinkCardBean.ᶥ(), substanceDeeplinkCardBean.ॱॱ());
        } else {
            ˋ(context, substanceDeeplinkCardBean, str, str2);
        }
    }

    private void ˎ(Context context, String str, String str2) {
        new dws(context, str, str2, this).ˏ(context);
    }

    private void ˋ(Context context, SubstanceDeeplinkCardBean substanceDeeplinkCardBean, String str, String str2) {
        int ˋ = dwv.ˋ(context, substanceDeeplinkCardBean.ॱॱ(), str, str2);
        if (ˋ != -2) {
            if (ˋ == -1) {
                new d(context, str, substanceDeeplinkCardBean.ㆍ()).execute(new Void[0]);
            }
            dgh.ˋ("340301", ˎ(evg.ॱ(str2, substanceDeeplinkCardBean.ॱॱ(), substanceDeeplinkCardBean.ᶥ(), dgm.ˎ((Activity) context), ˋ), substanceDeeplinkCardBean.ॱ(), substanceDeeplinkCardBean.ˊ()));
        }
    }

    public static LinkedHashMap<String, String> ˎ(LinkedHashMap<String, String> linkedHashMap, String str, String str2) {
        if (linkedHashMap == null) {
            linkedHashMap = new LinkedHashMap();
        }
        if (!TextUtils.isEmpty(str)) {
            linkedHashMap.put("logId", str);
        }
        if (!TextUtils.isEmpty(str2)) {
            linkedHashMap.put("logSource", str2);
        }
        return linkedHashMap;
    }

    public void aj_() {
        ˋ(this.ˏ, this.ˋ, this.ˎ, this.ˊ);
    }

    public void ak_() {
    }

    private void ॱ(Context context, SubstanceDeeplinkCardBean substanceDeeplinkCardBean) {
        String ᶥ = substanceDeeplinkCardBean.ᶥ();
        String ㆍ = substanceDeeplinkCardBean.ㆍ();
        String ˋ = dwv.ˋ(substanceDeeplinkCardBean.ॱॱ());
        if (((cdg) cdb.ॱ(cdg.class)).ˋ(ᶥ) == 11) {
            evk.ॱ(context.getString(n.ᐝʽ, new Object[]{ㆍ}));
            return;
        }
        SessionDownloadTask ˋ2 = dvt.ˏ().ˋ(ᶥ);
        if (ˋ2 != null) {
            int ˈ = ˋ2.ˈ();
            if (ˈ == 0 || ˈ == 2) {
                evk.ॱ(context.getString(n.ᐝʽ, new Object[]{ㆍ}));
                return;
            } else if (ˈ == 6) {
                evk.ॱ(context.getString(n.ॱﹳ, new Object[]{ㆍ}));
                return;
            } else {
                new dww(context, substanceDeeplinkCardBean, ˋ).ˏ();
                return;
            }
        }
        new dww(context, substanceDeeplinkCardBean, ˋ).ˏ();
    }
}
